package org.example.quartz;

import org.example.quartz.job.JobException;
import org.example.quartz.job.JobManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class QuartzJobService {
    @Autowired
    JobManager jobManager;

    public void addjob(String core, String key) throws JobException {
        jobManager.addJob(key, core, SomeOneJob.class);
    }

    public void midify(String core, String key) {
        try {
            jobManager.modifyJob(key, core);
        } catch (JobException e) {
            throw new RuntimeException(e);
        }
    }

    public void deleteJob(String key){
        try {
            jobManager.removeJob(key);
        } catch (JobException e) {
            throw new RuntimeException(e);
        }
    }
}
